<template>
  <div class="information">
    <van-tabs sticky swipeable @change="changeTab">
      <van-tab v-for="(item, index) in tabList" :key="index" :title="item.n">
        <!-- <info-flow :id="item.i"></info-flow> -->
        <scrollview :id="item.i"></scrollview>
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
import md5 from 'js-md5'
import InfoFlow from '../../components/InfoFlow'
import Scrollview from '../../components/ScrollView'

export default {
  components: {
    InfoFlow,
    Scrollview
  },
  data () {
    return {
      tabList: []
    }
  },
  onPageScroll () {
    wx.reportAnalytics('up_and_down_slide', {
    })
  },
  onLoad () {
    this.getInfoTab()
  },
  methods: {
    // 切换tab
    changeTab (e) {
      wx.reportAnalytics('hotspot_switch_chanel', {
      })
    },
    // 获取信息流频道
    getInfoTab () {
      const aid = '837d14e0b693f961'
      const pid = '1db990bec731c9d06951002b1c7b0811'
      const u = ''
      const v = '1.0.0'
      const m = 'wx'
      const d = ''
      const t = Date.now()
      const s = md5(u + '&' + v + '&' + m + '&' + d + '&' + t + '&' + aid)
      wx.request({
        url: 'https://nav.gionee.com/feed/channel.do',
        method: 'GET',
        data: {
          aid,
          pid,
          u,
          v,
          m,
          d,
          t,
          s
        },
        success: res => {
          this.tabList = res.data.data
        },
        fail: err => {
          console.log(err)
          wx.showLoading({
            title: '请检查网络'
          })
          setTimeout(() => {
            wx.hideLoading()
          }, 5000)
        }
      })
    }
  }
}
</script>
